package com.umiwe.permission.controller;

import com.umiwe.permission.service.UserDepartmentService;
import com.umiwe.utils.Result;
import com.umiwe.utils.ResultCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * 部门List
 * liximing
 */
@Api(description = "部门模块",tags = "UserDepartmentController")
@RestController
@RequestMapping("/api/department")
public class UserDepartmentController {

    @Autowired
    private UserDepartmentService userDepartmentService;

    /**
     * liximing
     */
    @GetMapping("/get/list")
    @ApiOperation(value="获取部门列表")
    public Result getDepartmentList(){
        return userDepartmentService.getDepartmentList();
    }

    /**
     * liximing
     */
    @PostMapping("/get/departmentId")
    @ApiOperation(value="获取部门详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "departmentId", value = "部门id", required = true, paramType = "form", dataType = "String"),
    })
    public Result getDepartmentDetails(@RequestParam(name = "departmentId")  String departmentId){
        if(StringUtils.isBlank(departmentId))
           return Result.error(ResultCode.DEPARTMENT_ID);
        return userDepartmentService.getDepartmentDetails(departmentId);
    }
}
